// 本模块用来调用首页接口与相关逻辑处理
import axios from 'axios';
import QS from 'qs';
export default {
  login(data) {
    let nowData = {
      phone: data.phone,
      password: data.password,
    }
    return axios({
      url: 'api/login',
      method: 'post',
      data: QS.stringify(nowData)
    })
  },
  codeLogin(data) {
    let nowData = {
      phone: data.phone,
      phone_code: data.phone_code,
    }
    return axios({
      url: 'api/login-code',
      method: 'post',
      data: QS.stringify(nowData)
    })
  },
  passwordCodeLogin(data) {
    let nowData = {
      phone: data.phone,
      password: data.password,
      phone_code: data.code,
    }
    return axios({
      url: 'api/login-pwc-code',
      method: 'post',
      data: QS.stringify(nowData)
    })
  },
  register(data) {
    let nowData = {
      phone: data.phone,
      password: data.password,
      name: data.name,
      phone_code: data.phone_code,
      email: data.email,
    }
    return axios({
      url: 'api/register',
      method: 'post',
      data: QS.stringify(nowData)
    })
  },
  logOut(data) {
    return axios({
      url: 'api/logout',
      method: 'post',
      data: {},
    })
  },
  sendSms(data) {
    return axios({
      url: 'api/send-sms',
      method: 'get',
      params: {
        mobile: data.mobile,
        type: data.type, //1:注册验证码,2：修改手机号,3:登录验证码;4:忘记密码
      }
    })
  },
  codeChangePwd(data) {
    let nowData = {
      phone: data.phone,
      new_password: data.new_password,
      phone_code: data.phone_code,
    }
    return axios({
      url: 'api/code-change-pwd',
      method: 'POST',
      data: QS.stringify(nowData)
    })
  },

}